<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>取派标准</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function(){
				// 先将body隐藏，再显示，不会出现页面刷新效果
				$("body").css({visibility:"visible"});
				
				// 收派标准信息表格
				$('#grid').datagrid( {
					iconCls : 'icon-forward',
					fit : true,
					border : false,
					rownumbers : true,
					striped : true,
					pageList: [2,10,30,50,100],
					pagination : true,
					toolbar : toolbar,
					url : "../../standard_pageQuery",
					idField : 'id',
					columns : columns
				});
				
				// 给save绑定单击事件
				$("#save").click(function(){
					if($("#standardForm").form('validate')){
						
						$.messager.confirm("success","你确定要保存该收派标准吗",function(r){
							if(r){
								$("#standardForm").submit();
							}
						})
						
					}else{
						$.messager.alert("error","你需要按照要求填写","warning")
					}
				})
			});	
			
			//工具栏
			var toolbar = [ {
				id : 'button-add',
				text : '增加',
				iconCls : 'icon-add',
				handler :doOpen
			}, {
				id : 'button-edit',
				text : '修改',
				iconCls : 'icon-edit',
				handler : doUpdate
			},{
				id : 'button-delete',
				text : '删除',
				iconCls : 'icon-cancel',
				handler : doDelete
			},{
				id : 'button-back',
				text : '恢复',
				iconCls : 'icon-back',
				handler : doBack
			}];
			// 还原方法
			function doBack(){
				$.messager.confirm("提示","你确定要恢复删除的收派标准吗",function(r){
					if(r){
						location.href = "../../standard_back";
					}
				})
			}
			// 定义删除方法
			function doDelete(){
				var select = $('#grid').datagrid('getSelections')
				
				if(select.length == 0){
					$.messager.alert("警告信息","删除操作至少要选择一条数据","warning")
				}else{
					$.messager.confirm("提示","你确定要删除选中的信息吗",function(r){
						if(r){
							// 确定删除  跳转到action操作 获取到id
							var select = $("#grid").datagrid('getSelections');
							var array = new Array();
							for (var i = 0; i < select.length; i++) {
								array[i] = select[i].id;
							}
							
							var ids = array.join();
							
							
							location.href = "../../standard_delete?ids="+ids;
						}
					})
				}
				
			}
			
			function doOpen(){
				$("#standardWindow").window('open')
			}
			// 定义修改方法
			function doUpdate(){
				/* 修改 */
				var select = $('#grid').datagrid('getSelections')
			
				if(select.length != 1){
					// 不是一条数据
					$.messager.alert("error","每次只能修改一条数据","warning");
				}else{
					// 选中的第一行数据
					var row = select[0];
					$('#standardForm').form('load',row);
					doOpen();
				};
			}
			// 定义列
			var columns = [ [ {
				field : 'id',
				checkbox : true
			},{
				field : 'name',
				title : '标准名称',
				width : 120,
				align : 'center'
			}, {
				field : 'minWeight',
				title : '最小重量',
				width : 120,
				align : 'center'
			}, {
				field : 'maxWeight',
				title : '最大重量',
				width : 120,
				align : 'center'
			}, {
				field : 'minLength',
				title : '最小长度',
				width : 120,
				align : 'center'
			}, {
				field : 'maxLength',
				title : '最大长度',
				width : 120,
				align : 'center'
			}, {
				field : 'operator',
				title : '操作人',
				width : 120,
				align : 'center'
			}, {
				field : 'operatingTime',
				title : '操作时间',
				width : 120,
				align : 'center'
			}, {
				field : 'company',
				title : '操作单位',
				width : 120,
				align : 'center'
			} ] ];
		</script>
	</head>

	<body class="easyui-layout" style="visibility:hidden;">
		<div region="center" border="false">
			<table id="grid"></table>
		</div>
		
		<div class="easyui-window" title="对收派标准进行添加或者修改" id="standardWindow" collapsible="false" minimizable="false" maximizable="false" modal="true" closed="true" style="width:600px;top:50px;left:200px">
			<div region="north" style="height:31px;overflow:hidden;" split="false" border="false">
				<div class="datagrid-toolbar">
					<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
				</div>
			</div>

			<div region="center" style="overflow:auto;padding:5px;" border="false">
				
				<form id="standardForm" action="../../standard_save" method="post">
					<table class="table-edit" width="80%" align="center">
						<tr class="title">
							<td colspan="2">收派标准信息
								<!--提供隐藏域 装载id -->
								<input type="hidden" name="id" />
							</td>
						</tr>
						<tr>
							<td>收派标准名称</td>
							<td>
								<input type="text" name="name" 
									class="easyui-validatebox" data-options="required:true" />
							</td>
						</tr>
						<tr>
							<td>最小重量</td>
							<td>
								<input type="text" name="minWeight" 
										class="easyui-numberbox" required="true" />
							</td>
						</tr>
						<tr>
							<td>最大重量</td>
							<td>
								<input type="text" name="maxWeight" class="easyui-numberbox" required="true" />
							</td>
						</tr>
						<tr>
							<td>最小长度</td>
							<td>
								<input type="text" name="minLength" class="easyui-numberbox" required="true" />
							</td>
						</tr>
						<tr>
							<td>最大长度</td>
							<td>
								<input type="text" name="maxLength" class="easyui-numberbox" required="true" />
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</body>

</html>